package br.ufrj.dcc.dm.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import br.ufrj.dcc.dm.exceptions.UnrecognizedBooleanValueException;

public class BooleanEvaluator
{

	private static final List<String> validTrue = new ArrayList<String>(Arrays.asList("yes", "true", "positive", "ok"));
	private static final List<String> validFalse = new ArrayList<String>(Arrays.asList("no", "false", "negative", "failure"));
	
	public static Boolean Evaluate(String value) throws UnrecognizedBooleanValueException
	{
		value = value.trim().toLowerCase();
		
		if(validTrue.contains(value))
		{
			return true;
		}
		
		if(validFalse.contains(value))
		{
			return false;
		}
		
		throw new UnrecognizedBooleanValueException(value);
	}
}
